package com.englishstudymachine;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.content.Context;
import android.widget.Toast;

public class Tools {
	public static String newLine=System.getProperty("line.separator");
	public static void ShowToast(String text,Context context){
	Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
		 }
	public static boolean isNumeric(String str){
		if(str==null) return false;
		
		  for (int i = str.length();--i>=0;){   
		   if (!Character.isDigit(str.charAt(i))){
		    return false;
		   }
		  }
		  return true;
		 }
	 public static boolean isChinese(char c) {  
		  
	        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);  
	  
	        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS  
	  
	                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS  
	  
	                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A  
	  
	                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION  
	  
	                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION  
	  
	                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {  
	  
	            return true;  
	  
	        }  
	  
	        return false;  
	  
	    }  
	  
	  
	  public static boolean SaveFile(String filePath,String content)
	  {
		 
		
		  try {
			  File ff=new File(filePath);
			 if(! ff.exists()) ff.createNewFile();
			  FileOutputStream out = new FileOutputStream(ff, true);
			out.write(content.getBytes());
			  out.close();
			  return true;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
		
		  
	  }
	  public static boolean isChinese(String strName) {  
	  
	        char[] ch = strName.toCharArray();  
	  
	        for (int i = 0; i < ch.length; i++) {  
	  
	            char c = ch[i];  
	  
	            if (isChinese(c) == true) {  
	                return true;  
	            } 
	  
	        }
	        return false;
	  
	    }  
}
